package com.dj.mingkong.portal.biz.repository.database.system;

import com.dj.mingkong.common.enums.StatusEnum;
import com.dj.mingkong.common.infrastructure.base.dto.query.QueryVo;
import com.dj.mingkong.common.infrastructure.base.repository.BaseDatabaseRepository;
import com.dj.mingkong.common.infrastructure.eo.database.system.DictionaryEo;
import com.dj.mingkong.portal.biz.repository.database.system.mapper.DictionaryMapper;
import org.springframework.stereotype.Repository;

import java.util.Optional;


/**
 * 数据字典repository
 *
 * @author zenglonghui
 * @date: 2022/5/18 11:51
 */
@Repository
public class DictionaryRepository extends BaseDatabaseRepository<DictionaryMapper, DictionaryEo, QueryVo> {
    public Optional<DictionaryEo> oneOptByFullKey(String fullKey) {
        return lambdaQuery()
                .eq(DictionaryEo::getFullKey, fullKey)
                .eq(DictionaryEo::getStatus, StatusEnum.VALID.getIntVal())
                .oneOpt();
    }

    public DictionaryEo oneByFullKey(String fullKey) {
        return lambdaQuery()
                .eq(DictionaryEo::getFullKey, fullKey)
                .eq(DictionaryEo::getStatus, StatusEnum.VALID.getIntVal())
                .one();
    }
}
